/*
 Navicat Premium Dump SQL

 Source Server         : 测试-35.13-3309
 Source Server Type    : MySQL
 Source Server Version : 50726 (5.7.26-log)
 Source Host           : 10.3.35.13:3309
 Source Schema         : rvt2ifc

 Target Server Type    : MySQL
 Target Server Version : 50726 (5.7.26-log)
 File Encoding         : 65001

 Date: 23/01/2025 16:18:26
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for project
-- ----------------------------
DROP TABLE IF EXISTS `project`;
CREATE TABLE `project` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
  `uuid` char(36) NOT NULL COMMENT '文件的唯一标识 UUID',
  `state` smallint(6) NOT NULL COMMENT '0json文件未生成，1json文件已生成',
  `project_name` varchar(255) NOT NULL COMMENT '项目名称',
  `description` text COMMENT '项目描述',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '项目创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='项目表，存储 BIM 项目信息';

-- ----------------------------
-- Records of project
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for project_mark
-- ----------------------------
DROP TABLE IF EXISTS `project_mark`;
CREATE TABLE `project_mark` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '标记唯一标识',
  `uuid` char(36) NOT NULL COMMENT '文件的唯一标识 UUID',
  `project_uuid` char(36) NOT NULL COMMENT '关联的项目 ID',
  `position_x` double NOT NULL COMMENT '标记的 X 坐标',
  `position_y` double NOT NULL COMMENT '标记的 Y 坐标',
  `position_z` double NOT NULL COMMENT '标记的 Z 坐标',
  `view_pos` varchar(255) NOT NULL COMMENT '拾取点时的仕途坐标',
  `entity_id` varchar(255) NOT NULL COMMENT '元素ID，还没搞太清楚',
  `number` varchar(255) NOT NULL COMMENT '编号',
  `title` varchar(255) NOT NULL COMMENT '标记的标题',
  `content` text NOT NULL COMMENT '标记的内容',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP  COMMENT '标记创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`),
  KEY `project_uuid` (`project_uuid`),
  CONSTRAINT `project_mark_ibfk_1` FOREIGN KEY (`project_uuid`) REFERENCES `project` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='轻量化模型标记表，记录模型中的标记信息';

-- ----------------------------
-- Records of project_mark
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for project_model_relation
-- ----------------------------
DROP TABLE IF EXISTS `project_model_relation`;
CREATE TABLE `project_model_relation` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
  `project_uuid` char(36) NOT NULL COMMENT '项目 ID',
  `xkt_model_uuid` char(36) NOT NULL COMMENT '轻量化模型 ID',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '关联创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `project_uuid` (`project_uuid`,`xkt_model_uuid`),
  KEY `xkt_model_uuid` (`xkt_model_uuid`),
  CONSTRAINT `project_model_relation_ibfk_1` FOREIGN KEY (`project_uuid`) REFERENCES `project` (`uuid`) ON DELETE CASCADE,
  CONSTRAINT `project_model_relation_ibfk_2` FOREIGN KEY (`xkt_model_uuid`) REFERENCES `xkt_model` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='项目与轻量化模型的关系表';

-- ----------------------------
-- Records of project_model_relation
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for uploaded_file
-- ----------------------------
DROP TABLE IF EXISTS `uploaded_file`;
CREATE TABLE `uploaded_file` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `uuid` char(36) NOT NULL COMMENT '文件的唯一标识 UUID',
  `file_name` varchar(255) NOT NULL COMMENT '文件原始名称',
  `pinyin_name` varchar(255) NOT NULL COMMENT '拼音名',
  `file_size` bigint(20) NOT NULL COMMENT '文件大小（字节）',
  `stored_name` varchar(255) NOT NULL COMMENT '存储的文件名',
  `upload_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP  COMMENT '上传时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='记录用户上传的文件信息';

-- ----------------------------
-- Records of uploaded_file
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for xkt_model
-- ----------------------------
DROP TABLE IF EXISTS `xkt_model`;
CREATE TABLE `xkt_model` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
  `uuid` char(36) NOT NULL COMMENT '文件的唯一标识 UUID',
  `uploaded_file_uuid` char(36) NOT NULL COMMENT '关联的 RVT 文件 ID',
  `state` smallint(6) NOT NULL COMMENT '0待转换，1转换完成，2转换中,3转换失败',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '轻量化模型创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`),
  KEY `uploaded_file_uuid` (`uploaded_file_uuid`),
  CONSTRAINT `xkt_model_ibfk_1` FOREIGN KEY (`uploaded_file_uuid`) REFERENCES `uploaded_file` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='轻量化模型表，存储导出的 metadata.json 和 geometry.xkt 文件信息';

-- ----------------------------
-- Records of xkt_model
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
